package com.example.walkingtour.data;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.SimpleCursorAdapter;
import android.widget.TextView;
import com.example.walkingtour.*;

public class MySimpleCursorAdapter extends SimpleCursorAdapter {
	public MySimpleCursorAdapter(Context context, int layout, Cursor c,
			String[] from, int[] to, int flags) {
		super(context, layout, c, from, to, flags);
	}

	@Override
	public void setViewText(TextView v, String text) {
		super.setViewText(v, convText(v, text));
	}

	private String convText(TextView v, String text) {
		double dblAmt;
		int i;
		switch (v.getId()) {
		case R.id.wtGPS_Lat:
			i = this.getCursor().getColumnIndex(WTDatabase.COL_GPS_LAT);
			dblAmt = this.getCursor().getDouble(i);
			return String.valueOf(dblAmt);
		case R.id.wtGPS_Long:
			i = this.getCursor().getColumnIndex(WTDatabase.COL_GPS_LONG);
			dblAmt = this.getCursor().getDouble(i);
			return String.valueOf(dblAmt);
		}
		return text;
	}
}